package com.twu.biblioteca;

public class User {
    private final String id;
    private final String password;
    private final String name;
    private String emailId;


    public User(String id, String password, String name, String emailId) {
        this.id = id;
        this.password = password;
        this.name = name;
        this.emailId = emailId;
    }

    public boolean matches(String id, String password) {
        return id.equals(this.id) && password.equals(this.password);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (!id.equals(user.id)) return false;
        if (!password.equals(user.password)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + password.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return name + "\n" + id + "\n" + emailId;
    }
}
